<template>
  <div class="container">
    <img :src="stampSrc">
  </div>
</template>
<script lang="ts" setup>
// svg
import stampDaiQianShu from '@/assets/icons/svg/stampDaiQianShu.svg' // 待签署
import stampDaiQueRen from '@/assets/icons/svg/stampDaiQueRen.svg' // 待确认
import stampYiBoHui from '@/assets/icons/svg/stampYiBoHui.svg' // 审核已驳回
import stampYiTongGuo from '@/assets/icons/svg/stampYiTongGuo.svg' // 审核已通过
import stampDaiShenHe from '@/assets/icons/svg/stampDaiShenHe.svg' // 待审核
import stampDaiQueRenOther from '@/assets/icons/svg/stampDaiQueRenOther.svg' // 待对方确认
import stampYiJuJue from '@/assets/icons/svg/stampYiJuJue.svg' // 已拒绝
import stampYiQueRenOther from '@/assets/icons/svg/stampYiQueRenOther.svg' // 对方已确认
import { computed, watch } from 'vue'

//defineProps
const props = defineProps({
  pageType: { //rentBox:租箱 callBackBox:回调箱
    type: String,
    default: 'rentBox'
  },
  rowData: {
    type: Object,
    default: () => ({})
  },
  rentSource: {
    type: String,
    default: '10' //订单源 5: '集装箱公司', 10: '货代' 
  },
})

const stampSrc = computed(() => {
  if (props.rentSource == '10') { //订单源 rentSource 集装箱公司-5；货代-10
    return stampSrcAgentPublish.value //集装箱公司订单 （货代发布）
  } else {
    return stampSrcBoxOwnnerPublish.value //货代订单 （集装箱公司发布） 注：租箱订单总是集装箱公司发布
  }
})

// 当前节点类型
// 租箱:5-货代操作员提交 10-集装箱公司操作员确认 15-货代操作员确认 20-集装箱公司管理员审核 25-货代管理员审核 30-E签宝签章
// 回调箱集装箱公司下单: 5 - 集装箱公司操作员提交 10 - 货代操作员确认 15 - 集装箱公司操作员确认 20 - 货代管理员审核 25 - 集装箱公司管理员审核 30 - E签宝签章
// 回调箱货代下单: 5 - 货代操作员提交 10 - 集装箱公司操作员确认 15 - 货代操作员确认 20 - 货代管理员审核 25 - 集装箱公司管理员审核 30 - E签宝签章

// 状态章-集装箱公司订单
const stampSrcAgentPublish = computed(() => {
  const companyRole = localStorage.getItem('companyRole') || ''
  if (!companyRole) return
  const rowData = props.rowData
  const currentNodeType = rowData.currentNodeType  //当前节点
  const frontNodeType = rowData.frontNodeType //上一个节点
  const frontNodeReviewStatus = rowData.frontNodeReviewStatus //上一个节点审核结果 5-通过 10-驳回
  // if (rowData.status >= 5 && rowData.status != 40) return '' //审核流程结束后
  // if (rowData.status <= 3 ||  ) return '' //审核流程结束后
  if (![2, 3, 15, 20, 40].includes(rowData.status)) return ''
  if (props.pageType === 'rentBox') { // 出租订单
    switch (currentNodeType) {
      case 5:
        return stampDaiQueRen
      case 10:
        if (companyRole === 'putBox') { // 租箱企业
          if (frontNodeType == 25) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          if (frontNodeType == 15) {
            return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
          }
          return stampDaiQueRen
        } else {
          return stampDaiQueRenOther
        }
      case 15:
        // return stampYiBoHui
        if (companyRole === 'putBox') { // 租箱企业
          return stampDaiQueRenOther
        } else {
          return stampYiQueRenOther
        }
      case 20://审核
        // return stampYiTongGuo
        if (companyRole === 'putBox') {
          return stampDaiShenHe // 集装箱公司管理员审核
        } else {
          return stampDaiShenHe
        }
      case 25:
        if (companyRole === 'putBox') {
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          return ''
        } else {
          return stampDaiShenHe  // 货代管理员审核
        }
      case 30:
        if (companyRole === 'putBox') {
          return stampDaiQianShu
        } else {
          return stampDaiQianShu
        }
      default: return ''
    }
  }
  if (props.pageType === 'callBackBox') { //回调订单
    // console.log(currentNodeType)
    // console.log(companyRole)
    // console.log(frontNodeType)
    switch (currentNodeType) {
      case 5:
        if (companyRole === 'putBox') { // 租箱企业
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiQueRen
        } else {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiQueRenOther
        }
      case 10:
        if (companyRole === 'putBox') { // 租箱企业
          // if (frontNodeType == 25) {
          //   return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          // }
          // if (frontNodeType == 15) {
          //   return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
          // }
          return stampDaiQueRenOther
        } else {
          if (frontNodeType == 15) {
            return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
          }
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampDaiQueRen : stampYiTongGuo
          }
          return stampDaiQueRen
        }
      case 15:
        // return stampYiBoHui
        if (companyRole === 'putBox') { // 租箱企业
          return stampYiQueRenOther // 11.28
        } else {
          return stampDaiQueRenOther
        }
      case 20://审核
        // return stampYiTongGuo
        if (companyRole === 'putBox') {
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          return stampDaiShenHe // 集装箱公司管理员审核
        } else {
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          return stampDaiShenHe
        }
      case 25:
        if (companyRole === 'putBox') {
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiShenHe
          }
          return ''
        } else {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
      case 30:
        if (companyRole === 'putBox') {
          return stampDaiQianShu
        } else {
          return stampDaiQianShu
        }
      case 35:
        if (companyRole === 'putBox') {
          return stampDaiQianShu
        } else {
          return stampDaiQianShu
        }
      default: return ''
    }
  }
})

// 状态章-货代订单
const stampSrcBoxOwnnerPublish = computed(() => {
  const companyRole = localStorage.getItem('companyRole') || ''
  if (!companyRole) return
  const rowData = props.rowData
  const currentNodeType = rowData.currentNodeType  //当前节点
  const frontNodeType = rowData.frontNodeType //上一个节点
  const frontNodeReviewStatus = rowData.frontNodeReviewStatus //上一个节点审核结果 5-通过 10-驳回
  // if (rowData.status >= 5 && rowData.status != 40) return '' //审核流程结束后
  // if (rowData.status <= 3 ||  ) return '' //审核流程结束后
  if (![2, 3, 15, 20, 40].includes(rowData.status)) return ''
  if (props.pageType === 'rentBox') { // 出租订单
    switch (currentNodeType) {
      case 5:
        return stampDaiQueRen
      case 10:
        if (companyRole === 'putBox') { // 租箱企业
          if (frontNodeType == 25) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          if (frontNodeType == 15) {
            return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
          }
          if (frontNodeType == 5) {
            // return null
            return stampDaiQueRen
          }
          return stampDaiQueRen
        } else {
          return stampDaiQueRenOther
        }
      case 15:
        // return stampYiBoHui
        if (companyRole === 'putBox') {
          return stampDaiQueRenOther
        } else {
          return stampYiQueRenOther
        }
      case 20://审核
        // return stampYiTongGuo
        if (companyRole === 'putBox') {
          return stampDaiShenHe
        } else {
          return stampDaiShenHe
        }
      case 25:
        if (companyRole === 'putBox') {
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          return ''
        } else {
          return stampDaiShenHe
        }
      case 30:
        if (companyRole === 'putBox') {
          return stampDaiQianShu
        } else {
          return stampDaiQianShu
        }
      default: return ''
    }
  }
  if (props.pageType === 'callBackBox') { //回调订单
    if (rowData.processBusinessType == 50) { // 二审
      return check2(currentNodeType, companyRole, frontNodeType, frontNodeReviewStatus)
    } else {
      return check1(currentNodeType, companyRole, frontNodeType, frontNodeReviewStatus)
    }
  }
  console.log(1111111111)
  if (props.pageType === 'dealBox') { // 箱贸易订单
    switch (currentNodeType) {
      case 5:
        return stampDaiQueRen
      case 10:
        if (companyRole === 'sellBox') { // 租箱企业
          if (frontNodeType == 25) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          if (frontNodeType == 15) {
            return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
          }
          // if (frontNodeType == 5) {
          //   return null
          // }
          return stampDaiQueRen
        } else {
          return stampDaiQueRenOther
        }
      case 15:
        // return stampYiBoHui
        if (companyRole === 'sellBox') {
          return stampDaiQueRenOther
        } else {
          return stampYiQueRenOther
        }
      case 20://审核
        // return stampYiTongGuo
        if (companyRole === 'sellBox') {
          return stampDaiShenHe
        } else {
          return stampDaiShenHe
        }
      case 25:
        if (companyRole === 'sellBox') {
          if (frontNodeType == 20) {
            return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
          }
          return ''
        } else {
          return stampDaiShenHe
        }
      case 30:
        if (companyRole === 'sellBox') {
          return stampDaiQianShu
        } else {
          return stampDaiQianShu
        }
      default: return ''
    }
  }
})

//回调订单 一审二审用章规则字典
const check1 = (currentNodeType, companyRole, frontNodeType, frontNodeReviewStatus) => {

  switch (currentNodeType) {
    case 5:
      console.log(currentNodeType)
      console.log(companyRole)
      console.log(frontNodeType)
      if (companyRole === 'putBox') { // 租箱企业
        return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiQueRen
      } else {
        return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiQueRen
      }
    case 10:
      if (companyRole === 'putBox') { // 租箱企业 
        if (frontNodeType == 5) {//
          return stampDaiQueRen
        }
        if (frontNodeType == 15) {//
          return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
        }
        if (frontNodeType == 20) {//
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        if (frontNodeType == 25) {//
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiQueRenOther
      } else {
        if (frontNodeType == 5) {//
          return stampDaiQueRenOther
        }
        if (frontNodeType == 15) { //
          return frontNodeReviewStatus == 10 ? stampDaiQueRenOther : stampYiTongGuo
        }
        if (frontNodeType == 20) {//
          return frontNodeReviewStatus == 10 ? stampDaiQueRenOther : stampYiTongGuo
        }
        if (frontNodeType == 25) {//
          return frontNodeReviewStatus == 10 ? stampDaiQueRenOther : stampYiTongGuo
        }
        return stampDaiQueRen
      }
    case 15:
      // return stampYiBoHui
      if (companyRole === 'putBox') { // 租箱企业
        return stampDaiQueRenOther
      } else {
        return stampYiQueRenOther
      }
    case 20://审核
      // return stampYiTongGuo
      if (companyRole === 'putBox') {
        if (frontNodeType == 20) {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiShenHe // 集装箱公司管理员审核
      } else {
        if (frontNodeType == 20) {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiShenHe
      }
    case 25:
      if (companyRole === 'putBox') {
        if (frontNodeType == 20) {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiShenHe
        }
        return ''
      } else {
        return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
      }
    case 30:
      if (companyRole === 'putBox') {
        return stampDaiQianShu
      } else {
        return stampDaiQianShu
      }
    case 35:
      if (companyRole === 'putBox') {
        return stampDaiQianShu
      } else {
        return stampDaiQianShu
      }
    default: return ''
  }
}
const check2 = (currentNodeType, companyRole, frontNodeType, frontNodeReviewStatus) => {
  switch (currentNodeType) {
    case 5:
      if (companyRole === 'putBox') { // 租箱企业
        // return stampDaiQueRen
        if (frontNodeType == 10) {
          return stampDaiQueRen
        }
        if (frontNodeType == 20) {
          return stampYiBoHui
        }
        if (frontNodeType == 25) {
          return stampYiBoHui
        }
      } else {
        if (frontNodeType == 10) {
          return stampDaiQueRenOther
        }
      }
      return stampDaiQueRenOther
    case 10:
      if (companyRole === 'putBox') { // 租箱企业 
        if (frontNodeType == 5) {//
          return stampDaiQueRenOther
        }
        if (frontNodeType == 15) {//
          return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
        }
        if (frontNodeType == 20) {//
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        if (frontNodeType == 25) {//
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiQueRenOther
      } else {
        if (frontNodeType == 5) {//
          return stampDaiQueRen
        }
        if (frontNodeType == 15) { //
          return frontNodeReviewStatus == 10 ? stampYiJuJue : stampYiTongGuo
        }
        if (frontNodeType == 20) {//
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        if (frontNodeType == 25) {//
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiQueRen
      }
    case 15:
      // return stampYiBoHui
      if (companyRole === 'putBox') { // 租箱企业
        return stampYiQueRenOther
      } else {
        return stampDaiQueRenOther
      }
    case 20://审核
      // return stampYiTongGuo
      if (companyRole === 'putBox') {
        if (frontNodeType == 20) {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiShenHe // 集装箱公司管理员审核
      } else {
        if (frontNodeType == 20) {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
        }
        return stampDaiShenHe
      }
    case 25:
      if (companyRole === 'putBox') {
        if (frontNodeType == 20) {
          return frontNodeReviewStatus == 10 ? stampYiBoHui : stampDaiShenHe
        }
        return ''
      } else {
        return frontNodeReviewStatus == 10 ? stampYiBoHui : stampYiTongGuo
      }
    case 30:
      if (companyRole === 'putBox') {
        return stampDaiQianShu
      } else {
        return stampDaiQianShu
      }
    case 35:
      if (companyRole === 'putBox') {
        return stampDaiQianShu
      } else {
        return stampDaiQianShu
      }
    default: return ''
  }
}

// watch(() => props.currentNodeType, (newVal, oldVal) => {
//   console.log(newVal)
// })

</script>
<style scoped>
.container {
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  float: right;
  margin: -50px -50px 0 0
}
</style>